package fr.ece.si.ing5.madboomview;

import fr.ece.si.ing5.madboom.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;

public class GamePlay extends Activity implements OnClickListener,
		OnTouchListener {
	private Button flagButton = null;
	private Button unknownButton = null;
	private Button revealButton = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_play);

		flagButton = (Button) findViewById(R.id.flag_button);
		unknownButton = (Button) findViewById(R.id.unknown_button);
		revealButton = (Button) findViewById(R.id.reveal_button);

		flagButton.setOnClickListener(this);
		flagButton.setOnTouchListener(this);
		unknownButton.setOnClickListener(this);
		unknownButton.setOnTouchListener(this);
		revealButton.setOnClickListener(this);
		revealButton.setOnTouchListener(this);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		switch (v.getId()) {
		case R.id.flag_button:
			flagButton.setBackground(getResources().getDrawable(
					R.drawable.flag2));
			break;

		case R.id.unknown_button:
			unknownButton.setBackground(getResources().getDrawable(
					R.drawable.unknown2));
			break;

		case R.id.reveal_button:
			revealButton.setBackground(getResources().getDrawable(
					R.drawable.reveal2));
			break;
		}
		return false;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.flag_button:
			flagButton.setBackground(getResources()
					.getDrawable(R.drawable.flag));
			break;

		case R.id.unknown_button:
			unknownButton.setBackground(getResources().getDrawable(
					R.drawable.unknown));
			break;

		case R.id.reveal_button:
			revealButton.setBackground(getResources().getDrawable(
					R.drawable.reveal));
			break;
		}
	}
}